package com.lifuixng.picturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lifuixng.picturebackend.common.DeleteRequest;
import com.lifuixng.picturebackend.manage.upload.UrlPictureUpload;
import com.lifuixng.picturebackend.model.dto.picture.*;
import com.lifuixng.picturebackend.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lifuixng.picturebackend.model.entity.User;
import com.lifuixng.picturebackend.model.vo.picture.PictureVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 26966
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2024-12-17 13:46:01
 */
public interface PictureService extends IService<Picture> {


    /**
     * 上传图片
     *
     * @param inputSource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);


    /**
     * 根据id删除图片
     *
     * @param deleteRequest
     * @return
     */
    int deleteById(DeleteRequest deleteRequest, HttpServletRequest request);


    /**
     * 编辑图片（用户使用）
     *
     * @param pictureEditRequest
     * @param request
     * @return
     */
    int editPicture(PictureEditRequest pictureEditRequest, HttpServletRequest request);

    /**
     * 更新图片（管理员）
     *
     * @param pictureUpdateRequest
     * @return
     */
    int updatePicture(PictureUpdateRequest pictureUpdateRequest, HttpServletRequest request);


    /**
     * 根据id获取图片(不需要脱敏)
     *
     * @param id
     * @return
     */
    Picture getPictureById(Long id);

    /**
     * 根据id获取图片信息（脱敏）
     *
     * @param id
     * @return
     */
    PictureVO getPictureVOById(Long id,HttpServletRequest request);


    /**
     * 图片校验
     *
     * @param picture
     */
    void verifyPicture(Picture picture);


    /**
     * 将单个图片脱敏
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);


    Page<Picture> pictureListByPage(PictureQueryRequest pictureQueryRequest);

    // 将Page<Picture> ====> Page<PictureVO>
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);


    /**
     * 将请求条件转换成条件构造器
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);



    Page<PictureVO> pictureVOListByPage(PictureQueryRequest pictureQueryRequest, HttpServletRequest request);

    /**
     * 填充审核状态参数
     *
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);


    /**
     * 图片审核功能
     * @param pictureReviewRequest
     * @param loginUser
     * @return
     */
    int doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);


    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest ,User loginUser);


    /**
     * 删除和编辑图片的权限校验
     * @param loginUser
     */
    void checkPictureAuth(User loginUser, Picture picture);

}
